Mad Blanks Support Forum
Hello mickeyrs November 13, 2007, 07:30:14 AM *
Show unread posts since last visit.
Show new replies to your posts.
Total time logged in: 1 hours and 44 minutes.
News: Mad Blanks 1.1.0 Beta 2 released on Oct 15, 2007
 
   Home   Help Search Profile My Messages Members Logout  
Pages: [1]
  Reply  |  Notify  |  Mark unread  |  Send this topic  |  Print  
Author Topic: Randomize questions from categories?  (Read 11 times)
mickeyrs
Newbie
*
Posts: 2


View Profile Email Personal Message (Online)
« on: November 12, 2007, 04:06:22 PM »
Reply with quoteQuote Modify messageModify Remove messageRemove



Report to moderator   77.105.29.28
chris
Administrator
Full Member
*****
Posts: 42


View Profile Email Personal Message (Offline)
« Reply #1 on: November 12, 2007, 06:52:18 PM »
Reply with quoteQuote

I'm so glad you like the component. Thank you for saying so.

There is no way to do what you want with configuration options, but those options are slated to be added in future releases.

However, to do what you want regarding choosing one question at random from a possible 20 questions, I came up with an experimental modification to the code that you can try if you're interested.

Once you make the modifications to the code, you will have to set the following Create Single Record module parameters when giving a quiz:

  • Fill in one field at a time and submit repeatedly, or fill in a whole record at once? should be set to Whole record at once (multiple fields on form). It should be set this way even though after modifying the code you will only see one randomly selected question given.
  • Allow submitted fields to be blank? If set to no, form submission is prevented unless all values are filled in. should be set to Yes

Here are the code modifications. These apply to version 1.1.0 Beta 2 of the Create Single Record module. The file to edit is installed at <joomla_root>/modules/mod_madblanks_createsinglerecord.php

Make a backup copy first!

Insert the following at line 627 (underneath if ($singleormultifield == 'multi') {):

Code:
        $choosefromfields = array();
        for ($i=1; $i <= $pgFieldCount; $i++) {
                $theindex = sprintf('%02d', $i); // sprintf (as opposed to printf) is used to put the value into a variable
                if ($configuration["data_" . $theindex . "_use"]) {
                        $choosefromfields[] = $i;
                }
        }
        $i = $choosefromfields[array_rand($choosefromfields)];


To "comment out" a line in this case means to add // at the beginning of the line.

Comment out line 634, so it looks like this:
Code:
        // for ($i=0; $i <= $pgFieldCount; $i++) {

Comment out line 752 (just a closing bracket), so it looks like this:
Code:
        // }
 

Once the modifications are made, the Score Scripts won't work quite right anymore, but you could still use something like this in your Score Script:

Code:
[:answers_correct:0:<start>:]<p>Because you answered ZERO questions correctly, you are seeing this.</p>[:answers_correct:0:<end>:]
[:answers_correct:1:<start>:]<p>Because you answered ONE question correctly, you are seeing this.</p>[:answers_correct:1:<end>:]

If you decide to try this, please let me know how it works.
Report to moderator   Logged
chris
Administrator
Full Member
*****
Posts: 42


View Profile Email Personal Message (Offline)
« Reply #2 on: November 12, 2007, 08:56:13 PM »
Reply with quoteQuote

To add the capability of having more possible answers for each question and then to have option that sets how many of them are displayed, try modifying the code as follows below. Note that this modification will apply to all quizzes on your site....

This modification applies to version 1.1.0 Beta 2 of the file <joomla_root>/administrator/components/com_madblanks/madblanks.class.php

Add the following at line 1845 (just before // Create an array of options)

Code:
                     shuffle($thechoices);
                        $thechoices = array_slice($thechoices, 0, 5);

                        if (array_search($configarray['multcorrect'], $thechoices) === false) {
                                $thechoices[0] = $configarray['multcorrect'];
                        }


Replace the 5 with your desired number of options to show up for each question. You should also have Display radio button, checkbox, or menu options to the website user in random order? If set to no, display in the order listed above. set to Yes for each question in the category setup.

Again, this is experimental, so let me know how it works if you try it!
Report to moderator   Logged
mickeyrs
Newbie
*
Posts: 2


View Profile Email Personal Message (Online)
« Reply #3 on: Today at 07:28:12 AM »
Reply with quoteQuote Modify messageModify Remove messageRemove

Report to moderator   147.91.1.43
Pages: [1]
  Reply  |  Notify  |  Add poll  |  Send this topic  |  Print  
  Remove Topic  |  Lock topic  
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC
Joomla Bridge by JoomlaHacks.com
Valid XHTML 1.0! Valid CSS!
 
  Design by augs-burg.de & go-vista.de
This is the official website for the Mad Blanks component for Joomla!
www.madblanks.org | Mad Blanks for Joomla! | ©2007 Chris Hallett
 
     
   
Design by go-vista.de and augs-burg.de